package com.hex.ds.hdrs.log.controller;


import com.hex.bigdata.hbda.annotation.Log;
import com.hex.bigdata.hbda.base.Page;
import com.hex.ds.hdrs.common.page.PageData;
import com.hex.ds.hdrs.log.po.RunningStateLog;
import com.hex.ds.hdrs.log.service.RunningStateLogService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 运行状况日志表 前端控制器
 * </p>
 *
 * @author tj
 * @since 2020-11-26
 */
@Slf4j
@RestController
@RequestMapping("/api/runningStateLog")
public class RunningStateLogController {

    @Autowired
    private RunningStateLogService runningStateLogService;

    @GetMapping("/selectPages")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> qryRunningStateLog(RunningStateLog runningStateLog, Page page) {
        log.info("进入了【RunningStateLogController】的qryRunningStateLog方法");
        PageData pageData = new PageData(this.runningStateLogService.queryrunningStateLog(runningStateLog, page), page);
        return new ResponseEntity<>(pageData, HttpStatus.OK);
    }

    @Log("查看节点运行记录")
    @ApiOperation("查看节点运行记录")
    @GetMapping(value = "/selectAgentStates")
    public ResponseEntity<Object> selectAgentStates(@RequestParam String agentCode) {
        log.info("进入了【RunningStateLogController的selectAgentStates方法】参数agentCode: {}", agentCode);
        return new ResponseEntity(this.runningStateLogService.selectAgentStates(agentCode), HttpStatus.OK);
    }

    @GetMapping("/findRunningStateLog")
    @ApiOperation("查询运行日志数据")
    public ResponseEntity<Object> findRunningStateLog() {
        log.info("进入了RunningStateLogController的qryRunningStateLog方法");
        List<RunningStateLog> list = this.runningStateLogService.findRunningStateLog();
        return new ResponseEntity<>(list, HttpStatus.OK);
    }

    @PostMapping("/initMasterRunningStateLog")
    @ApiOperation("初始化中心运行状况日志信息")
    public ResponseEntity<Object> initMasterRunningStateLog(@RequestParam Integer pageIndex) {
        log.info("进入了RunningStateLogController的initMasterRunningStateLog方法");
        List<RunningStateLog> list = this.runningStateLogService.initMasterRunningStateLog(pageIndex);
        return new ResponseEntity<>(list, HttpStatus.OK);
    }
}

